package lab3;

public class Interrupt {
	static class I_Athread extends Thread{
		public void run(){
			System.out.println("   Thread starting ...");
			int i = 0;
			while ( !isInterrupted() ){
				System.out.println("     " + i);
				i++;
			}
			System.out.println("   ... thread done!");
		}
	}
	/**
	 * @param args
	 * @throws InterruptedException 
	 */
	public static void main(String[] args) throws InterruptedException {
		System.out.println("Program starting ...");
		I_Athread t = new I_Athread();
		t.start();
		
		// Wait a few seconds
		Thread.sleep(2000);
		t.interrupt();
		
		// wait for t to be done:
		t.join();

		System.out.println("... program done!");
	}

}
